package com.chengzhi;

import com.chengzhi.netty.handler.ServerMessageConsumer;
import com.chengzhi.netty.server.NettyServer;
import com.chengzhi.nettycommoms.disruptor.MessageConsumer;
import com.chengzhi.nettycommoms.disruptor.RingBufferFactory;
import com.lmax.disruptor.BlockingWaitStrategy;
import com.lmax.disruptor.dsl.ProducerType;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class NettyServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(NettyServerApplication.class, args);
        MessageConsumer[] consumers = new MessageConsumer[4];
        for (int i = 0; i < consumers.length; i++) {
            MessageConsumer messageConsumer = new ServerMessageConsumer("server-consumer" + i);
            consumers[i] = messageConsumer;
        }
        RingBufferFactory.instance().init(ProducerType.MULTI, 1024 * 1024, new BlockingWaitStrategy(), consumers);
        new NettyServer();
    }
}
